package Demo;

import java.util.Scanner;

public class MyDemo2 {
    public static void main(String[] args) {
        String admin = "admin";
        String password = "123456";
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名登录");
        String user = scanner.nextLine();
        if(user.length() == 0){
            System.out.println("用户名不能为空");
            return;
        }
        for (int i = 0; i < user.length(); i++) {
            if ('0' < user.charAt(i) && user.charAt(i) < '9' ){
                System.out.println("用户名必须为字母，输入非法");
                return;
            }
        }
        System.out.println("请输入用户密码");
        String userpassword = scanner.nextLine();
        if (userpassword.length() == 0){
            System.out.println("用户密码不能为空");
            return;
        }
        for (int i = 0; i < userpassword.length(); i++) {
            if('A' < userpassword.charAt(i) && userpassword.charAt(i) < 'z'){
                System.out.println("密码必须为纯数字，输入非法");
                return;
            }
        }
        if(user.equals(admin)){
            if (password.equals(userpassword)){
                System.out.println("登录成功");
            }else {
                System.out.println("用户名和密码输入错误”,用户名保留,密码清空");
            }
        }else{
            System.out.println("“用户名和密码输入错误”,用户名和密码清空");
        }
    }
}
